<template>
  <div class="Login">
    <div class="top_hesder">
       <van-icon name="arrow-left" @click="retur" />
      <span>账号登录</span>
      <span></span>
    </div>
    <div class="contert_top">
      <el-form
        :model="ruleForm"
        status-icon
        :rules="rules"
        ref="ruleForm"
       
        class="demo-ruleForm"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
      >
        <!-- 密码 -->
        <el-form-item prop="password">
          <el-input
            type="password"
            v-model="ruleForm.password"
            autocomplete="off"
          ></el-input>
        </el-form-item>
        <!-- 账号 --> 
        <el-form-item prop="username">
          <el-input
            type="password"
            v-model="ruleForm.username"
            autocomplete="off"
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submitForm()">登录</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      ruleForm: {
        username: "123",
        password: "123",
      },
      rules: {
        username: [
          {
            required: true,
            message: "账号不正确",
            trigger: "blur",
          },
        ],
        password: [
          {
            required: true,
            message: "密码不正确",
            trigger: "blur",
          },
        ],
      },
    };
  },
  methods: {
    submitForm() {
      this.$refs.ruleForm.validate((valid) => {
        if (valid) {
          if (
            this.ruleForm.username === "123" &&
            this.ruleForm.password === "123"
          ) {
            sessionStorage.setItem("username", this.ruleForm.username);
            this.$router.push({ path: "/my" });
          } else {
            this.$alert("错误");
          }
        }
      });
    },
    retur(){
      this.$router.push("/Mye")
    }
  },
};
</script>

<style scoped lang="scss">
.login{
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #fff;
}
.top_hesder{
  width:100%;
  height: 50px;
  display: flex;
  justify-content: space-between;
  padding: 0 20px;
  align-items: center;
  background: #fff;
  border-bottom: 1px solid #ccc;
}
.contert_top{
  width: 100%;
  height: 400px;
  background: #fff;
  .el-form{
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 10px 20px;
  }
}
.element.style{
  width: 100%;
  margin-left: 0;
}
</style>
